package com.songlanyun.modules.usergains.service;


import com.songlanyun.common.enums.DistributionConstant;
import com.songlanyun.common.enums.MemberConstant;
import com.songlanyun.common.enums.OrderConstant;
import com.songlanyun.modules.account.model.vo.AccountParentVO;
import com.songlanyun.modules.gains.entity.ShopOrderGains;
import com.songlanyun.modules.usergains.entity.UserOrderGains;
import com.songlanyun.modules.usergains.model.UserOrderGainsTo;

import java.math.BigDecimal;
import java.util.List;

/**
 * 分销算法接口
 */
public interface IDistributionHandle
{
    List<UserOrderGains> handle(ShopOrderGains shopOrderGains );

    default UserOrderGainsTo  buildUserOrderGainsTo(AccountParentVO vo,
                                                    DistributionConstant.DistributionComputer distributionComputer,
                                                    DistributionConstant.DistributionType distributionType,
                                                    BigDecimal gains,
                                                    BigDecimal ratio,
                                                    String envRemark)
    {
        UserOrderGainsTo userOrderGainsTo = new UserOrderGainsTo();
        userOrderGainsTo.setVo(vo);
        userOrderGainsTo.setDistributionComputer(distributionComputer);
        userOrderGainsTo.setDistributionType(distributionType);
        userOrderGainsTo.setRatio(ratio);
        userOrderGainsTo.setGains(gains);
        userOrderGainsTo.setEnvRemark(envRemark);

        return userOrderGainsTo;
    }



    /**
     * 是否是县级代理或市级代理
     * @param vo
     * @return
     */
    default Boolean isCountyOrCityAgent(AccountParentVO vo)
    {
        return vo.getRoleCode().equals(MemberConstant.COUNTY_AGENT) ||vo.getRoleCode().equals(MemberConstant.CITY_AGENT);
    }

    /**
     * 是否是县级代理或市级代理
     * @param vo
     * @return
     */
    default Boolean isPartner(AccountParentVO vo)
    {
        return vo.getRoleCode().equals(MemberConstant.PARTNER);
    }



}
